#![no_std]
#![no_main]

mod sbi;
mod console;
mod lang_items;

use core::arch::global_asm;

use sbi::sleep;


global_asm!(include_str!("entry.asm"));
#[no_mangle]
pub fn rust_main()-> !{
    
    clear_bss();
    for i in [1,2]{
       sleep(1);
        info!("Hello, world!\n"); 
    }

    panic!("Shutdown machine!");
}

fn clear_bss(){
    extern  "C"{
        fn sbss();
        fn ebss();
    }
    (sbss as usize .. ebss as usize).for_each(
        |a|{
            unsafe {(a as *mut u8).write_volatile(0);}
        }
    );
}